import React, { useEffect } from "react";
import styles from "./index.module.less";
import Message from "../message";
import { connect } from "react-redux";
import { getMyLeaveMessageAction } from "@redux/actions02";

const MyMessages = (props) => {
    const { getMyLeaveMessageAction, list } = props;

    useEffect(() => {
        getMyLeaveMessageAction();
    }, [getMyLeaveMessageAction]);

    return (
        <div className={styles.my_messages}>
            {list &&
                list.map((item, index) => <Message key={index} item={item} />)}
        </div>
    );
};

export default connect((state) => ({ list: state.myLeaveMessageReducer }), {
    getMyLeaveMessageAction,
})(MyMessages);
